﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tcm.utils
{
    public class FileUtils
    {
        public static string getFileSeparator() 
        {
            string osInfo = Environment.OSVersion.VersionString.ToString();
            if (osInfo.Contains("Windows"))
            {
                return "\\";
            }
            else 
            {
                return "/";
            }

        }

        public static void createFilePath(string filePath) 
        {
            DirectoryInfo fileInfo = new DirectoryInfo(filePath);
            if (!fileInfo.Exists)
            {
                fileInfo.Create();
            }
        }

        public static string Base64Decode(Encoding encodeType, string result)
        {
            string decode;
            byte[] bytes = Convert.FromBase64String(result);
            try
            {
                decode = encodeType.GetString(bytes);
            }
            catch
            {
                decode = result;
            }
            return decode;
        }
    }
}
